package demo04;

/**
 * @author: WangPeng
 * @createTime: 2022/10/31 17:48
 * @description:
 * @version: v1.0
 */
public class Girl implements Runnable{
    private BankCard bankCard;
    public Girl(BankCard bankCard) {
        this.bankCard = bankCard;
    }
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            if (bankCard.getBalance()>=1000){
                bankCard.setBalance(bankCard.getBalance()-1000);
                System.out.println(Thread.currentThread().getName()+"从卡中去除1000，卡中余额为:"+bankCard.getBalance());
            }else{
                System.out.println("卡中余额不足");
            }
        }
    }
}
